package iit.projects.etaxi.model.entity;

import java.io.Serializable;
import java.util.Date;

public class Message implements Serializable {

	private static final long serialVersionUID = 8102789679720525909L;
	
	transient static final String STYLE_UNREAD = "font-weight: bold";
	transient static final String STYLE_READ = "font-style: italic";
	
	/**
	 * <p>Primary Key of the Message</p>
	 */
	private Long id;
	
	/**
	 * <P>Message Content</p>
	 */
	private String message;
	
	/**
	 * <P>States whether the message was read or not</P>
	 */
	private boolean read;
	
	/**
	 * <P>Time of Creation</P>
	 */
	private Date date;
	
	/**
	 * <P>Transient variable used for front end processing</P>
	 */
	transient boolean selected;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public boolean getRead() {
		return read;
	}

	public void setRead(boolean read) {
		this.read = read;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public boolean isSelected() {
		return selected;
	}

	public void setSelected(boolean selected) {
		this.selected = selected;
	}
	
	public String getStyle(){
		return (read)? STYLE_READ : STYLE_UNREAD;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Message other = (Message) obj;
		if (getId() == null) {
			if (other.getId() != null)
				return false;
		} else if (!getId().equals(other.getId()))
			return false;
		return true;
	}
}
